package com.stchou.superbrowser.ui.widget;

import com.stchou.superbrowser.activity.R;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

public class SuperExitDialog extends Dialog {

	private TextView mTitle; 
	private Button mSureButton;
	private ImageButton mCloseButton;

	public static class Builder {
		private SuperExitDialog mDialog;

		public Builder(Context context) {
			mDialog = new SuperExitDialog(context, R.style.SuperDialogTheme);
		}

		public Builder setTitle(String title) {
			mDialog.mTitle.setText(title);
			return this;
		}

	

		public Builder setSureButtonListener(
				android.view.View.OnClickListener listener) {
			mDialog.mSureButton.setOnClickListener(listener);
			return this;
		}

		public Builder setCloseButtonListener(
				android.view.View.OnClickListener listener) {
			mDialog.mCloseButton.setOnClickListener(listener);
			return this;
		}

		public Builder setSureButtonBackground(int resid) {
			mDialog.mSureButton.setBackgroundResource(resid);
			return this;
		}

		public Builder setCloseButtonBackground(int resid) {
			mDialog.mCloseButton.setBackgroundResource(resid);
			return this;
		}
		
		public Builder setSureButtonText(String string) {
			mDialog.mSureButton.setText(string);
			return this;
		}
	

		public SuperExitDialog show() {
			mDialog.show();
			return mDialog;
		}
		
		public void dismiss(){
			mDialog.dismiss();
		}

	}

	public SuperExitDialog(Context context) {
		super(context);
	}

	public SuperExitDialog(Context context, int theme) {
		super(context, theme);
		setContentView(R.layout.dialog_exit);
		mTitle = (TextView) findViewById(R.id.title);
		mSureButton = (Button) findViewById(R.id.sure_button);
		mCloseButton = (ImageButton) findViewById(R.id.close);
		mCloseButton
				.setOnClickListener(new android.view.View.OnClickListener() {

					public void onClick(View v) {
						dismiss();

					}
				});
	}

	public void setTitle(String title) {
		mTitle.setText(title);
	}


	public void setSureButtonListener(android.view.View.OnClickListener listener) {
		mSureButton.setOnClickListener(listener);
	}

	public void setCloseButtonListener(
			android.view.View.OnClickListener listener) {
		mCloseButton.setOnClickListener(listener);
	}

	public void setSureButtonBackground(int resid) {
		mSureButton.setBackgroundResource(resid);
	}

	public void setCloseButtonBackground(int resid) {
		mCloseButton.setBackgroundResource(resid);
	}

}
